package com.sgcc.fj.pmos.e_fj_personalcenter.presenter;

import com.sgcc.fj.pmos.common.base.BasePresenter;
import com.sgcc.fj.pmos.common.http.HttpInterConst;
import com.sgcc.fj.pmos.common.http.HttpRequestUtils;
import com.sgcc.fj.pmos.common.http.MvpNetCallback;
import com.sgcc.fj.pmos.e_fj_personalcenter.bean.CollectionBean;
import com.sgcc.fj.pmos.e_fj_personalcenter.contract.FocusContract;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

public class FocusPresenter extends BasePresenter<FocusContract.View> implements FocusContract.Presenter {


    @Override
    public void getFocusList(int pageSize, boolean isLoading) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("ustatus", "01");
        params.put("ptype", "0");
        params.put("ratioId", "1");
        params.put("membersUserId", "");
        params.put("membersSdId", "");
        HttpRequestUtils.getInstance().request(params, HttpInterConst.USER_COLLECTION, new MvpNetCallback<CollectionBean>(getView(), isLoading) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
                getView().queryFailed();
            }

            @Override
            public void onResponse(CollectionBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().querySuccess(response);
            }
        });
    }
}
